$(function () {
	vm.studentId = getQueryString("studentId");
	vm.getMentorList();
});

var vm = new Vue({
	el:'#mapp',
	data:{
		studentId:'',
		//导师列表
		bsnMentorList: {},
		pageParams: {
			limit: "500",
			page: "1"
		}
	},
	methods: {
		//读取项目进展
		getXmjz: function(){
			$.get(ajaxServerUrlG("bsnXmjz/info/xmjz"), function(r){
                vm.bsnXmjz = r.bsnGonggao;
            });
		},
		getMentorList: function(){
			$.ajax({
				type: "POST",
			    url: ajaxServerUrlG("bsnmentor/list"),
                contentType: "application/json",
			    data: JSON.stringify(vm.pageParams),
			    success: function(r){
			    	if(r.code === 0){
						vm.bsnMentorList = r.page.list;
					}else{
						alert(r.msg);
					}
				}
			});
		},
		assignMentor: function(mentorId) {
			if (StringUtils.isEmpty(vm.studentId)) return;
			
			$.ajax({
				type: "POST",
			    url: ajaxServerUrlG("bsnstudent/assignMentor"),
                contentType: "application/json",
			    data: JSON.stringify({
			    	studentId: vm.studentId,
			    	mentorId: mentorId
				}),
			    success: function(r){
			    	if(r.code === 0){
						alert("分配成功!");
					}else{
						alert(r.msg);
					}
				}
			});
		}
	},
	filters: {
		/*过滤并替换头像 */
		imgFilter: function (imgUrl, xingb) {
			// console.log(imgUrl);
			if (StringUtils.isNotEmpty(imgUrl)) {
				return imgUrl;
			}
			if (xingb == "男") {
				return "images/man@2x.png";
			} else {
				return "images/woman@2x.png";
			}
		}
	}
});